<?php
class userModel
{
	private $db;
	
	public function __construct(){
		$this->db = getDB();
	}
    public function getAll()
    {
        $stmt = $this->db->prepare("select * from shop_user");
        $stmt->execute();
        return $stmt->fetch(PDO::ASSOC);
    }
    
    public function checkName($v = '')
    {
    	if(!$v)
    		return false;
    	$stmt = $this->db->query("SELECT `id` FROM `shop_user` WHERE `username` = '$v'");
    	return $stmt->fetch();
    }
    public function checkLogin($p='')
    {
      
    }
    public function regist($p='')
    {
        if(isset($p['username']) && $p['username'] && isset($p['password']) && isset($p['password']))
        {
			$uid = 1;
			$time = time();
            return $this->db->exec("INSERT INTO `shop_user`(`username`,`password`,`email`,`createtime`,`uid`) VALUES('{$p['username']}', '{$p['password']}', '{$p['email']}', $time, $uid)");
        }else{
            return false;
        }
    }
}
